/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lojavirtual.util;

import java.sql.Connection;
import javax.naming.InitialContext;
import javax.sql.DataSource;

/**
 *
 * @author 710930
 */
public class ConnectionFactory {

    public static Connection getConnection(){

        try {
            InitialContext context = new InitialContext();
            DataSource dataSource = (DataSource)context.lookup("jdbc/lojavirtual");
            return dataSource.getConnection();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return null;
    }
    
    public static void close(Connection connection){
        try{ connection.close(); }
        catch(Exception e){ e.printStackTrace();}
    }

}
